package com.qianbei.user.sharecode;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.qianbei.R;
import com.qianbei.common.base.BaseActivity;
import com.qianbei.common.codeshare.QRCode;
import com.qianbei.common.image.ImageLoaderFactory;
import com.qianbei.common.init.SetData;
import com.qianbei.share.ui.ShareFragmentDialog;

import static com.qianbei.common.init.SetData.getCareer;
import static com.qianbei.common.init.SetData.getFace;
import static com.qianbei.common.init.SetData.getUserName;

/**
 * Created by gml on 16/12/12.
 */

public class ShareCodeActivity extends BaseActivity {


    private ImageView iv_user_icon;
    private TextView tv_sharecode_name;
    private TextView tv_sharecode_postion;
    private ImageView tv_sharecode_img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.share_code_activity);
        mTitle.setRightImage(R.drawable.code_right_img);
        setTitle("我的二维码");
//
    }

    @Override
    public void fClick(int id) {

        switch (id){
            case  R.id.title_right:
                ShareFragmentDialog dialogs = ShareFragmentDialog.newInstance("我是"+SetData.getUserName()+"("+getCareer() +")"+"来「前辈」向我提问","前辈 — 向专业人士提问，获取一对一个性化答案。",String.format(PERSONAL_URL, SetData.getUserID()),URL + getFace(),"web",true);
                dialogs.show(getFragmentManager(), this.getClass().toString());
            break;
        }
        super.fClick(id);
    }


    @Override
    public void initView() {

        String  codString  ="http://qianbei.jiemian.com/qianbei/users/info/";
        iv_user_icon = (ImageView) findViewById(R.id.iv_user_icon);
        tv_sharecode_name = (TextView) findViewById(R.id.tv_sharecode_name);
        tv_sharecode_postion = (TextView) findViewById(R.id.tv_sharecode_postion);
        tv_sharecode_img = (ImageView) findViewById(R.id.tv_sharecode_img);
        tv_sharecode_img.setImageBitmap(QRCode.createQRCode(String.format(PERSONAL_URL, SetData.getUserID())));
        tv_sharecode_name.setText(getUserName());
        tv_sharecode_postion.setText(getCareer());
        ImageLoaderFactory.getInstance().displayImage(getApplicationContext(), iv_user_icon, URL + getFace());
    }
}
